import java.io.File;



public class MsgParserMain {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		
		if (args.length != 2) {
			System.out.println("wrong use");
			System.exit(1);
		}
		
//		File thisDir = new File(MsgParserMain.class.getResource("").getPath()).getParentFile().getParentFile();
//		System.out.println("Execution directory : " + thisDir);
		//File analyzedDir = new File(thisDir.getAbsolutePath() + "\\files\\vmg\\221108");
		File analyzedDir = new File(args[0]);
		
		System.out.println("Analyzed directory : " + analyzedDir);
		File[] files = null;
		
		if (!analyzedDir.exists()){
			throw new Exception(analyzedDir + " does  not exist : fail");
		} else if (analyzedDir.isFile()) {
			throw new Exception(analyzedDir + "is not a directory : fail.");
		} else if (analyzedDir.isDirectory()) {
			files = analyzedDir.listFiles();
			
			if (files == null){
				throw new Exception("No file found in " + analyzedDir + " : fail.");
			}
		}
		Analyzer analyzer = new Analyzer(new File(args[1], "result.txt"));
		
		for (int i = 0; i < files.length; i++) {
			analyzer.analyze(files[i]);
		}
		System.out.println("Result file : " + analyzer.getOutput());
		analyzer.finalize();
		System.out.println("done.");
		
//		DataDispatcher dispatcher = new DataDispatcher(new File(
//							"C:\\Users\\Seb\\Documents\\java\\dispatch - Copie"));
//		UIcreator uiCreator = new UIcreator(dispatcher);
//		uiCreator.setFiles(dispatcher.getNames());
//		uiCreator.createUI();
//		System.out.println(dispatcher.getNames());
//		dispatcher.finalize();
	}
}
